// JointRegularSet.h: interface for the JointRegularSet class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_JOINTREGULARSET_H__7B30B8C1_321B_4361_AF8E_4F54B904E1BA__INCLUDED_)
#define AFX_JOINTREGULARSET_H__7B30B8C1_321B_4361_AF8E_4F54B904E1BA__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "JointRegular.h"
#include "Part.h"
#include "ManagerTemplate.h"
class JointFunction;
#include "JointPortFormer.h"
#include "ObjectGenerator.h"
#include "DataSet.h"
#include "Register.h"
#include "GeneralJointRegular.h"

class SpecialJointRegularInfo;
class AFX_EXT_CLASS JointRegularSet : public ManagerTemplate<CString, GeneralJointRegular>  
{
	typedef RegisterTemplate<DWORD, SpecialJointRegularInfo*> SpecialJointRegularSet;
	typedef ObjectGenerator<SpecialJointRegularSet> SpecialJointRegularSetGenerator;
public:
	JointRegularSet();
	virtual ~JointRegularSet();

public:
	void GetJointAttach(Joint* pJoint);
	JointRegular* GenerateRegular(JointFunction* pFirst, JointFunction* pNext);
	BOOL IsLegal(INT nFirstStyle, INT nSecondStyle);
	JointRegular* GenerateRegular(INT nFirstStyle, INT nSecondStyle);

	static SpecialJointRegularSet& GetSpecialJointRegularSet();
private:
	const _ConnectionPtr& GetRegularSetDB();
	JointRegular* GenerateSpecialRegular(JointFunction *pFirst, JointFunction *pNext);
	void ReadRegular();
	void NewRegular(_RecordsetPtr& rs);

private:
	const CString& GetID(Part* pPart);
	void GetAttach(_RecordsetPtr& rs, Joint* pJoint);

private:
	BOOL HasJointed(Part& part, JointSystem::JointPortFormer* pFormer);
	void CloseConnection();
	_ConnectionPtr m_pCon;
	CString m_strRegularSetTableName; 
	CString m_strDBPath;
	BOOL m_bIsRead;

private:
	static SpecialJointRegularSetGenerator m_RegularSetGenerator;
};

typedef ObjectGenerator<JointRegularSet> JointRegularSetGenerator;

//AFX_EXT_API JointRegularSet& GetJointRegularSet();
#endif // !defined(AFX_JOINTREGULARSET_H__7B30B8C1_321B_4361_AF8E_4F54B904E1BA__INCLUDED_)
